---
artifact: {{ .ModuleName }}/metallb-artifact
from: {{ .Images.BASE_GOLANG_20_ALPINE }}
git:
  - add: /{{ $.ModulePath }}modules/381-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
    to: /patches
    stageDependencies:
      install:
        - '**/*'
shell:
  install:
    - apk add --no-cache git
    - mkdir -p /src
    - cd /src
    - git clone -b v0.13.12 {{ $.SOURCE_REPO }}/metallb/metallb.git .
    - git config --global user.email "builder@deckhouse.io"
    # https://github.com/metallb/metallb/pull/2004
    # Remove cherry-pick when this commit is included in the release
    - git cherry-pick 667ab7e93d1e6465d5b6d343b73b3c7b1edd5015
    - find /patches -name '*.patch' | xargs git apply --verbose
    - export GO_VERSION=${GOLANG_VERSION}
    - export GOPROXY={{ $.GOPROXY }}
    - cd controller
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /controller
    - chown 64535:64535 /controller
    - chmod 0700 /controller
    - cd ../speaker
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /speaker
    - chown 64535:64535 /speaker
    - chmod 0755 /speaker
